<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>p2_CSS选择器</title>
    <style>
        <!--
        标签名选择器-- >
        div {
            color: red;
        }

        p {
            color: blue;
        }

        h4 {
            color: green;
        }

        h2 {
            color: yellow;
        }

        #d1 {
            color: aqua;
        }

        .ERROR {
            background-color: red;
        }

        .SUCESS {
            background-color: green;
        }

        .msg {
            color: white;
        }

        /*hover表示悬停状态 并列选择器：紧挨着在一起，必须同时生效*/
        #d1:hover {
            background-color: pink;
        }

        a:link {
            color: gray;
        }

        a:visited {
            color: green;
        }

        a:hover {
            color: red;
        }

        a:active {
            color: blue;
        }

        /*群组选择器*/
        #d1, p, .ERROR {
            font-style: italic;
            border: 5px solid purple;
        }

        * {
            font-style: italic;
        }

        input[type="text"] {
            background-color: yellow;
            color: red;
        }

        /*后代选择器带空格*/
        #d2 span {
            background-color: lightblue;
        }

        #d2 > div > p > span {
            background-color: lightgreen;
        }
    </style>
</head>
<body>
<div>我是div</div>
<div id="d1">我是div</div>
<p>我是p</p>
<h4>我是h4</h4>
<h2>我是h2</h2>
<hr>
<span class="ERROR msg">用户名不能为空</span>
<span class="ERROR msg">密码不能为空</span>
<span class="SUCESS msg">邮箱正确</span>
<span class="SUCESS msg">手机号正确</span>

<a href="http://www.baidu.com">超链接 1</a>
<a href="httidu.com">超链接 2</a>

<hr>
<input type="text">text
<input type="password">pwd
<hr>
<div id="d2">
    <span>1111</span>
    <div>
        <span>222</span>
        <p>测试</p>
        <p>我是<span>测试</span>段落</p>
    </div>
    <span>333</span>
</div>
</body>
</html>